package br.com.main.client.system.morador;

import java.util.ArrayList;
import java.util.List;

import br.com.main.client.system.botoes.FinanceiroView;
import br.com.main.client.system.botoes.FinanceiroView.Financas;
import br.com.main.client.system.morador.FinanceiroPresenterM.Display;

import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.datepicker.client.DateBox;

public class FinanceiroViewM extends Composite implements Display{

	
	
	private HorizontalPanel panelMain;
	private VerticalPanel pagamento;
	private VerticalPanel panelLeft;

	private HTML botaoPagSeguro = new HTML();
	private TextBox tbPesquisar;
	


	private TextBox tbValorTotal;
	private List<Financas> financeiro;
	private CellTable<Financas> tabela;


	
	DateBox dateBox = new DateBox();

	public static class Financas {
		private String valor;
		private String desrcricao;
		private String data;

		public Financas(String valor, String descricao, String data) {
			this.valor = valor;
			this.desrcricao = descricao;
			this.data = data;
		}
	}
	
	public FinanceiroViewM() {
		init();
		initWidget(panelMain);
	}

	private void init() {
		panelMain = new HorizontalPanel();
		panelMain.setSpacing(25);
		panelMain.setBorderWidth(1);

		panelLeft = new VerticalPanel();
		pagamento = new VerticalPanel();
		pagamento.setSpacing(5);
		tbPesquisar = new TextBox();
		financeiro = new ArrayList<Financas>();
		tabela = new CellTable<Financas>();
		tabela.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);

		TextColumn<Financas> valorColumn = new TextColumn<FinanceiroViewM.Financas>() {

			@Override
			public String getValue(Financas object) {
				// TODO Auto-generated method stub
				return object.valor;
			}
		};
		tabela.addColumn(valorColumn, "Valor");

		TextColumn<Financas> envolvidosColumn = new TextColumn<FinanceiroViewM.Financas>() {

			@Override
			public String getValue(Financas object) {
				// TODO Auto-generated method stub
				return object.data;
			}
		};
		tabela.addColumn(envolvidosColumn, "Data");

		TextColumn<Financas> descricaoColumn = new TextColumn<FinanceiroViewM.Financas>() {

			@Override
			public String getValue(Financas object) {
				// TODO Auto-generated method stub
				return object.desrcricao;
			}
		};
		tabela.addColumn(descricaoColumn, "Descrição");
		
		

		tabela.setRowCount(financeiro.size(), true);
		tabela.setRowData(0, financeiro);
	
		
		tbValorTotal = new TextBox();
		tbValorTotal.setEnabled(false);
		pagamento.add(new Label("Total das Despesas:"));
		pagamento.add(tbValorTotal);
		pagamento.add(botaoPagSeguro);
		

		panelLeft.setBorderWidth(1);
		panelLeft.setSpacing(5);
		panelLeft.add(new Label("Pesquisar "));
		panelLeft.add(tbPesquisar);
		panelLeft.add(new Label("Lista dos gastos"));
		panelLeft.add(tabela);
		panelLeft.add(pagamento);


		panelMain.add(panelLeft);
	}

	@Override
	public List<FinanceiroViewM.Financas> getList() {
		return financeiro;
	}

	@Override
	public void atualizaTabela() {
		tabela.setRowCount(financeiro.size(), true);
		tabela.setRowData(0, financeiro);
	}
	@Override
	public HTML getBotaoPagSeguro() {
		return botaoPagSeguro;
	}
	@Override
	public TextBox getTbValorTotal() {
		return tbValorTotal;
	}
	@Override
	public TextBox getTbPesquisar() {
		return tbPesquisar;
	}

}